package com.bnzj.cloud.business.core.persistence.repository;

import com.bnzj.cloud.business.core.persistence.entity.SysResourceMeta;
import com.bnzj.core.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Barry
 * @createDate 2020/3/27
 * @description
 */
@Repository
public interface SysResourceMetaRepository extends BaseRepository<SysResourceMeta, Long> {
    @Query(value = "SELECT rm.resource_id menuId, meta.*  " +
            "FROM bnz_sys_resource_rel_meta rm " +
            "LEFT JOIN bnz_sys_resource_meta meta ON rm.meta_id = meta.id " +
            "WHERE rm.resource_id = ?"
            , nativeQuery = true)
    List<SysResourceMeta> findByResourceId(Long resouceId);

    List<SysResourceMeta> findByIdIn(List<Long> metas);
}
